package net.kazed.nextaction.database.serialize;

import java.util.Date;

import android.database.Cursor;

/**
 * Query to retrieve backup file summary.
 * @author Koert Zeilstra
 */
public class BackupFileSummaryQuery {

    private Cursor cursor;

    /**
     * Constructor.
     * @param cursor Cursor to retrieve data.
     */
    public BackupFileSummaryQuery(Cursor cursor) {
        super();
        this.cursor = cursor;
    }
    
    /**
     * Get the first BackupFileSummary.
     * @return Retrieved summary.
     */
    public BackupFileSummary getBackupFileSummary() {
        BackupFileSummary summary = null;
        cursor.moveToFirst();
        summary = new BackupFileSummary(new Date(cursor.getLong(BackupSummaryCursor.INDEX_ID)),
                        cursor.getInt(BackupSummaryCursor.INDEX_NUMBER_OF_CONTEXTS),
                        cursor.getInt(BackupSummaryCursor.INDEX_NUMBER_OF_TASKS));
        return summary;
    }
}
